package com.atguigu.gmall.product;

import io.swagger.models.auth.In;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @Author: lx
 * @Time: 15:41
 * @Description:
 */
public class StreamDemo {

    public static void main(String[] args) {
        List<Map<String, Integer>> listMap = new ArrayList<>();
        Map<String, Integer> map1 =new HashMap<>();
        map1.put("k",67);
        Map<String, Integer> map2 =new HashMap<>();
        map2.put("k",98);
        listMap.add(map1);
        listMap.add(map2);

        List<Map<String, Integer>> collect = listMap.stream().sorted((o1, o2) -> {
            return  o2.get("k") - o1.get("k");
        }).collect(Collectors.toList());


        collect.forEach(map -> {
            System.out.println(map.get("k"));
        });
    }
}
